<template>
    <!-- 成绩列表 -->
    <h2>成绩</h2>
    <table cellspacing="0">
        <tr>
            <td>科目</td>
            <td>分数</td>
        </tr>
        <tr>
            <td>{{ info.list[8].name }}</td>
            <td>{{ info.list[8].score }}</td>
        </tr>
    </table>
    <!-- 折线图 -->
    <h2>成绩变化</h2>
    <div id="main9"></div>
</template>

<script setup lang="ts">
import * as echarts from 'echarts';
import { nextTick } from 'vue';
import { defineProps, onMounted, ref } from 'vue'

const info = defineProps(["list"]);
const score = info.list[8].score


onMounted(() => {
    nextTick(() => {
        type EChartsOption = echarts.EChartsOption;
        var chartDom = document.getElementById('main9')!;
        var myChart = echarts.init(chartDom);
        var option: EChartsOption;

        option = {
            title: {
                text: '地理分析',
                left: 'center'
            },
            tooltip: {
                trigger: 'item',
                formatter: '{a} <br/>{b} : {c} ({d}%)'
            },
            legend: {
                bottom: 10,
                left: 'center',
                data: ['选择', '非选择', '失分']
            },
            series: [
                {
                    type: 'pie',
                    radius: '65%',
                    center: ['50%', '50%'],
                    selectedMode: 'single',
                    data: [
                        { value: 100 - score, name: '失分'},
                        { value: score * 0.3, name: '选择' },
                        { value: score * 0.7, name: '非选择' },
                    ],
                    emphasis: {
                        itemStyle: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };

        option && myChart.setOption(option);
    })

})


</script>

<style scoped lang="scss">
h2 {
    height: 30px;
    padding-left: 10px;
    background-color: #74ede4;
    line-height: 30px;
}

table {
    width: 300px;
    height: 150px;
    margin: 5px auto 0;
    text-align: center;
    font-size: 20px;

    tr,
    td {
        border: 1px solid black;
    }
}

#main9 {
    height: 400px;
}
</style>